#ifndef _PARTICLES_H_
#define _PARTICLES_H_

#include "render.h"

struct particle
{
	particle()
	{
		alive = false;
	}
	vector3 pos;
	vector3 oldpos;
	vector3 vel;
	vector3 acc; // Accelerate
	u32     age;
	float   size;
	bool    alive;
};

struct ptc_vertex
{
	ptc_vertex(){}
	ptc_vertex(vector3 _pos,u32 _clr,vector2 _texcoord)
	{
		pos = _pos;
		color = _clr;
		tex = _texcoord;
	}

	vector3 pos;
	u32		color;
	vector2 tex;
};

class emitter
{
public:
	emitter(u32 _sz,vector3 _pos,texture* _tex);
	virtual ~emitter();

	virtual void reset();
	virtual void set_def(u32 _i)=0;

	virtual void update(u32 _dt)=0;
	virtual void draw()=0;

	void set_pos(vector3 _pos){m_pos = _pos;}

protected:
	ptc_vertex  m_vrt[4];
	texture*  m_texture;
	particle* m_particles;
	u32		  m_size;
	vector3   m_pos;
};

class smoke: public emitter
{
public:
	smoke(u32 _sz,vector3 _pos,float _height,texture* _tex);
	void set_def(u32 _i);
	void update(u32 _dt);
	void draw();
private:
	float m_height;
};

class exploser: public emitter
{
public:
	exploser(u32 _sz,float _radius,texture* _tex);

	void set_def(u32 _i);
	void update(u32 _dt);
	void draw();

	void exploid(vector3 _pos, u32 _sz, float _diam);

private:
	float m_radius;
	u32   m_cntr;
};

#endif